package com.store.controller;

import com.store.entity.Order;
import com.store.service.impl.OrderServiceImpl;
import com.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cai
 * @since 2022-07-21
 */
@RestController
@RequestMapping("orders")
public class OrderController extends BaseController {

    @Autowired
    OrderServiceImpl orderService;
    //GET ?aid=14&cids=12&cids=9&cids=8
    @RequestMapping("create")
    public JsonResult<Order> getCartListToPay(Integer aid, Integer[] cids, HttpSession session){
        Order order= orderService.addOrder(aid,cids,getUsernameFromSession(session));
//        System.out.println("create正常");
//        return "OK";
        return new JsonResult<>(OK,order);
    }
}
